import java.util.Scanner;
public class Strings
{
   public static void main (String[] args)
   {
      System.out.println("Please enter a string: ");
      Scanner in = new Scanner(System.in);
      String str = in.nextLine();
      int lens=str.length();
      System.out.println("Please enter a value for n: ");
      int n = in.nextInt();
      String ans="";
      for(int i=lens-n;i<lens;i++)
      {
         ans+=str.charAt(i);
      }
      System.out.println(ans);
   }
}